<!DOCTYPE html>
<html lang="zh">
	<head>
		<meta charset="UTF-8">
		<title>location对象</title>
	</head>
	<body>
		
		<input type="button" value="显示location对象" onclick="click1()" />
		<input type="button" value="改变地址" onclick="click2()" />
		<script type="text/javascript">
			function click1(){
				var href=window.location.href;
				alert(href);
				var hostname=window.location.hostname;
				var pathname=window.location.pathname;
				var port=window.location.port;
				var pro=window.location.protocol;
				
				alert("hostname:"+hostname);
				alert("pathname:"+pathname);
				alert("port:"+port);
				alert("pro:"+pro);
			}
			function click2(){
				//window.location.href="http://www.163.com";
				window.location="http://www.163.com";
			}
		</script>
	</body>
</html>
